/**
 * @Author: easten
 * @Created: 2024-07-21 18:10:10
 * @Description: 设备产品分类接口
 *
 */
import { IotDeviceGroup } from "_common/entity";
import { createRequest, RequestMethod } from "_common/request";
import { AxiosInstance } from "axios";

export class ApiDeviceGroup {
  /**
   * @description 请求实例
   * @type {RequestMethod}
   * @memberof ApiDevice
   * */
  request: RequestMethod;
  url: string = "api/iot/device-group/";

  /**
   * @description 构造函数
   * @param config axios 配置
   */
  public constructor(instance: AxiosInstance) {
    // axios 实例化
    this.request = createRequest(instance);
  }

  /** 创建属性 */
  createDeviceGroup(data: IotDeviceGroup) {
    return this.request.post<boolean>(this.url + "", data);
  }

  /** 更新属性 */
  updateDeviceGroup(data: IotDeviceGroup) {
    return this.request.put<boolean>(this.url + "", data);
  }

  /** 删除属性 */
  deleteDeviceGroup(id: number) {
    return this.request.delete<boolean>(this.url + "" + id);
  }

  /** 获取属性信息 */
  getDeviceGroupInfo(id: number) {
    return this.request.get<IotDeviceGroup>(this.url + "get-attr", { id });
  }

  /** 获取属性列表 */
  getDeviceGroupList() {
    return this.request.get<IotDeviceGroup[]>(this.url + "get-list");
  }

  // 获取属性分页列表
  getPageList(params: any) {
    return this.request.get<any>(this.url + "get-page", params);
  }

  // 启用，停用网关
  enable(id: number, enable: boolean) {
    return this.request.get<any>(this.url + "enable/" + id, {
      isEnable: enable,
    });
  }
}
